<?php 
set_time_limit(0);
ini_set("memory_limit", "12M");
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include '../connection/connection.php';
$winH = 520;

//inputfrom input_hourfrom input_munitefrom input_secondfrom inputto input_hourto input_muniteto input_secondto re_monitor re_camera re_total re_unrecognize re_fail re_ok
	$inputfrom = $_REQUEST['inputfrom'];
	$input_hourfrom = $_REQUEST['input_hourfrom'];
	$input_munitefrom = $_REQUEST['input_munitefrom'];
	$input_secondfrom = $_REQUEST['input_secondfrom'];
	$inputto = $_REQUEST['inputto'];
	$input_hourto = $_REQUEST['input_hourto'];
	$input_muniteto = $_REQUEST['input_muniteto'];
	$input_secondto = $_REQUEST['input_secondto'];
	$re_monitor = $_REQUEST['re_monitor'];
	$re_camera = $_REQUEST['re_camera'];
	$re_total = $_REQUEST['re_total'];
	$re_unrecognize = $_REQUEST['re_unrecognize'];
	$re_fail = $_REQUEST['re_fail'];
	if($re_fail=="") $re_fail=0;
	$re_ok = $_REQUEST['re_ok'];
	$re_user = $_REQUEST['re_user'];
	
	$fromdate = $inputfrom." ".$input_hourfrom.":".$input_munitefrom.":".$input_secondfrom;
	$todate = $inputto." ".$input_hourto.":".$input_muniteto.":".$input_secondto;
	
	if ($re_total==0) {
		$percent = 100;
	}
	else $percent = intval((floatval($re_ok) /$re_total)*100);
	
	$savequery = "insert into recognize(fromdate,todate,cameraid,total,unrecognize,recognize_ok,recognize_fail,percent,createdate,createuser)"
	." values('$fromdate','$todate',$re_camera,$re_total,$re_unrecognize,$re_ok,$re_fail,$percent,'NOW()',$re_user)";
	//echo $savequery;
	mysql_query($savequery,$connection);
	
	//reload
	$s_monitor = $re_monitor;
	$winH = 500;
	if(isset($_REQUEST['winH'])) $winH = $_REQUEST['winH'];
	$recognizeList = mysql_query("select re.*,co.`name` from recognize re,configcamera co where re.cameraid=co.id and re.fromdate='".$fromdate."' and re.todate='".$todate."' and co.id=$re_camera");
	$s_recognize = array();
	$index_re = 0;
	while($row_re = mysql_fetch_array($recognizeList)){
		$index_re +=1;
		array_push($s_recognize, array($row_re['name'],$row_re['total'],$row_re['unrecognize'],$row_re['recognize_fail'],$row_re['recognize_ok'],$row_re['percent'],$row_re['fromdate'],$row_re['todate'],$row_re['cameraid']));
		?>
	<tr>
		<td width="6%" align="center"><?=$index_re?></td>
		<td width="44%" align="center">
			<span onclick="OnSelect('<?=$row_re['fromdate']?>','<?=$row_re['todate']?>',<?=$row_re['cameraid']?>,<?=$row_re['total']?>,<?=$row_re['unrecognize']?>,<?=$row_re['recognize_fail']?>,<?=$row_re['recognize_ok']?>)" style="cursor:pointer;color:#035a97">
				<?=$row_re['name']?>
			</span>
		</td>
		<td width="10%" align="center"><?=$row_re['total']?></td>
		<td width="10%" align="center"><?=$row_re['unrecognize']?></td>
		<td width="10%" align="center"><?=$row_re['recognize_fail']?></td>
		<td width="10%" align="center"><?=$row_re['recognize_ok']?></td>
		<td width="10%" class="last" align="center"><?=$row_re['percent']."%"?></td>
	</tr>
	<?php }
	$_SESSION['s_recognizes'] = $s_recognize;
	if ($index_re<$winH/28) {
	 	foreach(range(0,$winH/28-$index) as $i){
	 		?>
	 		<tr>
	 		<td width="6%">&nbsp;</td>
		 	<td width="44%">&nbsp;</td>
		 	<td width="10%">&nbsp;</td>
		 	<td width="10%">&nbsp;</td>
		 	<td width="10%">&nbsp;</td>
		 	<td width="10%">&nbsp;</td>
		 	<td  width="10%"  class="last">&nbsp;</td>
		 	</tr>
	 	<?php }
	}
       		
mysql_close($connection);

?>  